package edu.lsnu.equipment_management_system.mapper.select.paging;

import edu.lsnu.equipment_management_system.pojo.vo.out.admin.*;
import edu.lsnu.equipment_management_system.pojo.vo.sql_conditions.PageBeginAndPageSizeVo;
import edu.lsnu.equipment_management_system.pojo.vo.sql_conditions.PageBeginPageSizeAndEquipmentNoVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author mzy
 * @Description 这个是后台管理员操作模板的mapper
 * @date 2018/11/16
 */
public interface AdminOptionMapperWithPaging {

    // --------------购入list--------------
    /**
     * @Description 后台管理员查看购入并且审核日期为空的设备【缩略】
     * @author mzy
     * @time 2018-11-16
     * @see
     * @return   java.util.List<edu.lsnu.equipment_management_system.pojo.po.AdminMsgInVo>
     * @params  []
     */
    @Select("select YHB.ZGH 'userNo', YHB.XM 'userName', \n" +
            "JBXX_SB_TMP.SBMC 'equipmentName', JBXX_SB_TMP.SBBH 'equipmentNo'\n" +
            "from \n" +
            "(\n" +
            "\tselect JBXX_SB.SBBH, JBXX_SB.SBMC \n" +
            "\tfrom JBXX_SB \n" +
            "\t-- 审核日期为空的，并且来源是购入的\n" +
            "\twhere JBXX_SB.SHRQ is null\n" +
            "\tand JBXX_SB.SBLY = '购入'\n" +
            ") JBXX_SB_TMP\n" +
            "inner join JBXX_SBSY\n" +
            "on JBXX_SBSY.SBBH = JBXX_SB_TMP.SBBH\n" +
            "inner join YHB on JBXX_SBSY.ZGH = YHB.ZGH\n" +
            "order by equipmentNo offset #{pageBegin} rows fetch next #{pageSize} rows only")
    List<AdminMsgInVo> getEquipmentPurchaseBasicListVo(PageBeginAndPageSizeVo pageBeginAndPageSizeVo);

    /**
     * @Description 后台管理员查看购入并且审核日期为空的设备【缩略】count
     * @author mzy
     * @time 2018-11-23
     * @see
     * @return   int
     * @params  []
     */
    @Select("select count(JBXX_SB_TMP.SBBH)\n" +
            "from \n" +
            "(\n" +
            "\tselect JBXX_SB.SBBH, JBXX_SB.SBMC \n" +
            "\tfrom JBXX_SB \n" +
            "\t-- 审核日期为空的，并且来源是购入的\n" +
            "\twhere JBXX_SB.SHRQ is null\n" +
            "\tand JBXX_SB.SBLY = '购入'\n" +
            ") JBXX_SB_TMP\n" +
            "inner join JBXX_SBSY\n" +
            "on JBXX_SBSY.SBBH = JBXX_SB_TMP.SBBH\n" +
            "inner join YHB on JBXX_SBSY.ZGH = YHB.ZGH")
    int getEquipmentPurchaseBasicListVoCount();

    // --------------购入详情--------------
    /**
     * @Description 管理员查看具体购入的详情
     * @author mzy
     * @time 2018-11-16
     * @see
     * @return   java.util.List<edu.lsnu.equipment_management_system.pojo.vo.admin_resource.AdminEquipmentPurchaseVo>
     * @params  [id] equipmentNo
     */
    @Select("select \n" +
            "DM_SBLB.SBLB 'equipmentCategory', \n" +
            "DM_CFCS.CFCS 'place',\n" +
            "DM_SBZT.SBZT 'useStatus',\n" +
            "DM_YHLB.YHLB 'userCategory',\n" +
            "DM_YJS.YJSMC 'teacherOffice',\n" +
            "YHB.ZGH 'userNo',\n" +
            "YHB.XM 'userName',\n" +
            "JBXX_SB.SBBH 'equipmentNo',\n" +
            "JBXX_SB.SBMC 'equipmentName',\n" +
            "JBXX_SB.XH 'type',\n" +
            "JBXX_SB.GG 'guiGe',\n" +
            "JBXX_SB.ZJZT 'depreciationStatus',\n" +
            "DM_SBLB.ZJNX 'depreciationPeriod',\n" +
            "JBXX_SB.DJ 'price',\n" +
            "JBXX_SB.CHPHM 'shippingNo',\n" +
            "JBXX_SB.GHDW 'deliveryUnit',\n" +
            "JBXX_SB.JHRQ 'purchaseDate',\n" +
            "JBXX_SB.YT 'application',\n" +
            "JBXX_SB.CCCJ 'manufacturer',\n" +
            "JBXX_SB.ZZH 'manufacturerNo',\n" +
            "JBXX_SB.BZ 'remark'\n" +
            "from JBXX_SB \n" +
            "inner join DM_SBLB\n" +
            "on JBXX_SB.SBLBDM = DM_SBLB.SBLBDM\n" +
            "inner join \n" +
            "(\n" +
            "\tselect JBXX_SBSY.ZGH, JBXX_SBSY.SBBH, JBXX_SBSY.BZ, JBXX_SBSY.CFCSDM\n" +
            "\tfrom JBXX_SBSY\n" +
            "\tinner join (\n" +
            "\t\tselect JBXX_SBSY.SBBH, MIN(JBXX_SBSY.SYRQ1) 'RQ'\n" +
            "\t\tfrom JBXX_SBSY\n" +
            "\t\tgroup by JBXX_SBSY.SBBH\n" +
            "\t) t\n" +
            "\ton JBXX_SBSY.SBBH = t.SBBH and JBXX_SBSY.SYRQ1 = t.RQ\n" +
            ") JBXX_SBSY_TMP\n" +
            "on JBXX_SB.SBBH = JBXX_SBSY_TMP.SBBH\n" +
            "inner join DM_CFCS\n" +
            "on JBXX_SBSY_TMP.CFCSDM = DM_CFCS.CFCSDM\n" +
            "inner join DM_SBZT\n" +
            "on JBXX_SB.SBZTDM = DM_SBZT.SBZTDM\n" +
            "inner join YHB\n" +
            "on YHB.ZGH = JBXX_SBSY_TMP.ZGH\n" +
            "inner join DM_YHLB\n" +
            "on YHB.YHLBDM = DM_YHLB.YHLBDM\n" +
            "inner join DM_YJS\n" +
            "on YHB.YJSDM = DM_YJS.YJSDM\n" +
            "where JBXX_SB.SBLY='购入' and JBXX_SB.SBBH = #{equipmentNo}")
    AdminEquipmentPurchaseVo getEquipmentPurchaseDetailVo(String equipmentNo); // 20180163

    // --------------调入list--------------
    /**
     * @Description 后台管理员查看调入并且审核日期为空的设备【缩略】
     * @author mzy
     * @time 2018-11-16
     * @see
     * @return   java.util.List<edu.lsnu.equipment_management_system.pojo.po.AdminMsgInVo>
     * @params  []
     */
    @Select("select YHB.ZGH 'userNo', YHB.XM 'userName', \n" +
            "JBXX_SB_TMP.SBMC 'equipmentName', JBXX_SB_TMP.SBBH 'equipmentNo'\n" +
            "from \n" +
            "(\n" +
            "\tselect JBXX_SB.SBBH, JBXX_SB.SBMC \n" +
            "\tfrom JBXX_SB \n" +
            "\t-- 设备来源是调入的\n" +
            "\twhere JBXX_SB.SBLY = '调入'\n" +
            ") JBXX_SB_TMP\n" +
            "inner join JBXX_SBSY\n" +
            "on JBXX_SBSY.SBBH = JBXX_SB_TMP.SBBH\n" +
            "inner join YHB on JBXX_SBSY.ZGH = YHB.ZGH\n" +
            "inner join JBXX_DRDC on JBXX_DRDC.SBBH = JBXX_SB_TMP.SBBH\n" +
            "-- 调入调出中是调入的\n" +
            "where JBXX_DRDC.DCDR = '调入' and JBXX_DRDC.SHRQ is null\n" +
            "order by equipmentNo offset #{pageBegin} rows fetch next #{pageSize} rows only")
    List<AdminMsgInVo> getEquipmentTransferInBasicListVo(PageBeginAndPageSizeVo pageBeginAndPageSizeVo);

    /**
     * @Description  后台管理员查看调入并且审核日期为空的设备【缩略】总计
     * @author mzy
     * @time 2018-11-23
     * @see
     * @return   int
     * @params  []
     */
    @Select("select count(JBXX_SB_TMP.SBBH)\n" +
            "from \n" +
            "(\n" +
            "\tselect JBXX_SB.SBBH, JBXX_SB.SBMC \n" +
            "\tfrom JBXX_SB \n" +
            "\t-- 设备来源是调入的\n" +
            "\twhere JBXX_SB.SBLY = '调入'\n" +
            ") JBXX_SB_TMP\n" +
            "inner join JBXX_SBSY\n" +
            "on JBXX_SBSY.SBBH = JBXX_SB_TMP.SBBH\n" +
            "inner join YHB on JBXX_SBSY.ZGH = YHB.ZGH\n" +
            "inner join JBXX_DRDC on JBXX_DRDC.SBBH = JBXX_SB_TMP.SBBH\n" +
            "-- 调入调出中是调入的\n" +
            "where JBXX_DRDC.DCDR = '调入' and JBXX_DRDC.SHRQ is null")
    int getEquipmentTransferInBasicListVoCount();

    // --------------调入详情--------------
    /**
     * @Description 管理员查看：具体调入的详情
     *      * @author mzy
     * @time 2018-11-16
     * @see
     * @return   java.util.List<edu.lsnu.equipment_management_system.pojo.vo.admin_resource.AdminEquipmentTransferInVo>
     * @params  [id] equipmentNo
     */
    @Select("select \n" +
            "DM_SBLB.SBLB 'equipmentCategory', \n" +
            "DM_CFCS.CFCS 'place',\n" +
            "DM_SBZT.SBZT 'useStatus',\n" +
            "DM_YHLB.YHLB 'userCategory',\n" +
            "DM_YJS.YJSMC 'teacherOffice',\n" +
            "YHB.ZGH 'userNo',\n" +
            "YHB.XM 'userName',\n" +
            "JBXX_SB.SBBH 'equipmentNo',\n" +
            "JBXX_SB.SBMC 'equipmentName',\n" +
            "JBXX_SB.XH 'type',\n" +
            "JBXX_SB.GG 'guiGe',\n" +
            "JBXX_SB.ZJZT 'depreciationStatus',\n" +
            "DM_SBLB.ZJNX 'depreciationPeriod',\n" +
            "JBXX_SB.DJ 'price',\n" +
            "JBXX_SB.CHPHM 'shippingNo',\n" +
            "JBXX_SB.GHDW 'deliveryUnit',\n" +
            "JBXX_SB.JHRQ 'purchaseDate',\n" +
            "JBXX_SB.YT 'application',\n" +
            "JBXX_SB.CCCJ 'manufacturer',\n" +
            "JBXX_SB.ZZH 'manufacturerNo',\n" +
            "JBXX_SB.BZ 'remark',\n" +
            "JBXX_SB.SBLY 'transerIn',\n" +
            "JBXX_DRDC_TMP.CRRQ 'transerDate',\n" +
            "JBXX_DRDC_TMP.CRYY 'transerReason',\n" +
            "JBXX_DRDC_TMP.DCDW 'transerOutUnit',\n" +
            "JBXX_DRDC_TMP.DRDW 'transerInUnit'\n" +
            "from JBXX_SB \n" +
            "inner join DM_SBLB\n" +
            "on JBXX_SB.SBLBDM = DM_SBLB.SBLBDM\n" +
            "inner join \n" +
            "(\n" +
            "\tselect JBXX_SBSY.ZGH, JBXX_SBSY.SBBH, JBXX_SBSY.BZ, JBXX_SBSY.CFCSDM\n" +
            "\tfrom JBXX_SBSY\n" +
            "\twhere JBXX_SBSY.SYRQ2 is null\n" +
            ") JBXX_SBSY_TMP\n" +
            "on JBXX_SB.SBBH = JBXX_SBSY_TMP.SBBH\n" +
            "inner join DM_CFCS\n" +
            "on JBXX_SBSY_TMP.CFCSDM = DM_CFCS.CFCSDM\n" +
            "inner join DM_SBZT\n" +
            "on JBXX_SB.SBZTDM = DM_SBZT.SBZTDM\n" +
            "inner join YHB\n" +
            "on YHB.ZGH = JBXX_SBSY_TMP.ZGH\n" +
            "inner join DM_YHLB\n" +
            "on YHB.YHLBDM = DM_YHLB.YHLBDM\n" +
            "inner join DM_YJS\n" +
            "on YHB.YJSDM = DM_YJS.YJSDM\n" +
            "inner join (\n" +
            "\tselect JBXX_DRDC.SBBH, JBXX_DRDC.ZGH, JBXX_DRDC.CRRQ, JBXX_DRDC.CRYY,\n" +
            "\tJBXX_DRDC.DRDW, JBXX_DRDC.DCDW\n" +
            "\tfrom JBXX_DRDC\n" +
            "\t-- 调入调出表中保证是调入的数据\n" +
            "\twhere JBXX_DRDC.DCDR = '调入'\n" +
            ") JBXX_DRDC_TMP\n" +
            "on JBXX_SB.SBBH = JBXX_DRDC_TMP.SBBH\n" +
            "-- 基本信息中保证设备来源是调入的\n" +
            "where JBXX_SB.SBLY = '调入' and JBXX_SB.SBBH = #{equipmentNo}") // 20131129
    AdminEquipmentTransferInVo getEquipmentTransferInDetailVo(String equipmentNo); // 20110127

    // --------------维修维护list--------------
    /**
     * @Description 管理员查看：维修维护列表
     * @author mzy
     * @time 2018-11-16
     * @see 
     * @return   java.util.List<edu.lsnu.equipment_management_system.pojo.vo.admin_resource.AdminMsgInVo>
     * @params  []
     */
    @Select("select \n" +
            "JBXX_WHWX.ZGH 'userNo',\n" +
            "YHB.XM 'userName',\n" +
            "JBXX_WHWX.SBBH 'equipmentNo',\n" +
            "JBXX_SB.SBMC 'equipmentName',\n" +
            "JBXX_WHWX.XHRQ1 'beginDate'\n" +
            "from JBXX_WHWX\n" +
            "inner join YHB\n" +
            "on YHB.ZGH = JBXX_WHWX.ZGH\n" +
            "inner join JBXX_SB\n" +
            "on JBXX_SB.SBBH = JBXX_WHWX.SBBH\n" +
            "where JBXX_WHWX.SHRQ is null \n" +
            "order by equipmentNo offset #{pageBegin} rows fetch next #{pageSize} rows only\n")
    List<AdminMsgInRepairVo> getEquipmentRepairBasicListVo(PageBeginAndPageSizeVo pageBeginAndPageSizeVo);

    /**
     * @Description 管理员查看：维修维护列表count
     * @author mzy
     * @time 2018-11-23
     * @see 
     * @return   
     * @params  []
     */
    @Select("select \n" +
            "count(JBXX_WHWX.SBBH)\n" +
            "from JBXX_WHWX\n" +
            "inner join YHB\n" +
            "on YHB.ZGH = JBXX_WHWX.ZGH\n" +
            "inner join JBXX_SB\n" +
            "on JBXX_SB.SBBH = JBXX_WHWX.SBBH\n" +
            "where JBXX_WHWX.SHRQ is null")
    int getEquipmentRepairBasicListVoCount();

    // --------------维修维护详情--------------
    /**
     * @Description 管理员查看：具体的维修维护的详情
     * @author mzy
     * @time 2018-11-16
     * @see
     * @return   edu.lsnu.equipment_management_system.pojo.vo.admin_resource.AdminEquipmentRepairVo
     * @params  [id] equipmentNo
     */
    @Select("select \n" +
            "DM_SBLB.SBLB 'equipmentCategory',\n" +
            "JBXX_SB.SBMC 'equipmentName',\n" +
            "JBXX_SB.SBBH 'equipmentNo',\n" +
            "YHB.XM 'handMan',\n" +
            "JBXX_WHWX.XHRQ1 'repairDate',\n" +
            "JBXX_WHWX.XHYY 'repairReason',\n" +
            "JBXX_WHWX.XHDD 'repairPlace',\n" +
            "JBXX_WHWX.XHRY 'repairMan',\n" +
            "JBXX_WHWX.XHFY 'repairMoney'\n" +
            "from JBXX_WHWX\n" +
            "inner join JBXX_SB\n" +
            "on JBXX_WHWX.SBBH = JBXX_SB.SBBH\n" +
            "inner join DM_SBLB\n" +
            "on JBXX_SB.SBLBDM = DM_SBLB.SBLBDM\n" +
            "inner join YHB\n" +
            "on JBXX_WHWX.ZGH = YHB.ZGH \n" +
            "where \n" +
            "JBXX_WHWX.SHRQ is null and \n" +
            "JBXX_SB.SBBH = #{equipmentNo}\n")
    AdminEquipmentRepairVo getEquipmentRepairDetailVo(String equipmentNo); // 20030817

    // --------------调出list--------------
    /**
     * @Description 管理员查看：调出列表
     * @author mzy
     * @time 2018-11-16
     * @see 
     * @return   java.util.List<edu.lsnu.equipment_management_system.pojo.vo.admin_resource.AdminMsgInVo>
     * @params  []
     */
    @Select("select YHB.ZGH 'userNo', YHB.XM 'userName', \n" +
            "JBXX_SB.SBMC 'equipmentName', JBXX_SB.SBBH 'equipmentNo'\n" +
            "from JBXX_DRDC\n" +
            "inner join YHB on JBXX_DRDC.ZGH = YHB.ZGH\n" +
            "inner join JBXX_SB on JBXX_DRDC.SBBH = JBXX_SB.SBBH\n" +
            "where JBXX_DRDC.DCDR = '调出' and JBXX_DRDC.SHRQ is null\n" +
            "order by equipmentNo offset #{pageBegin} rows fetch next #{pageSize} rows only")
    List<AdminMsgInVo> getEquipmentTransferOutBasicListVo(PageBeginAndPageSizeVo pageBeginAndPageSizeVo);

    /**
     * @Description 管理员查看：调出列表count
     * @author mzy
     * @time 2018-11-23
     * @see
     * @return
     * @params  []
     */
    @Select("select count(JBXX_SB.SBBH)\n" +
            "from JBXX_DRDC\n" +
            "inner join YHB on JBXX_DRDC.ZGH = YHB.ZGH\n" +
            "inner join JBXX_SB on JBXX_DRDC.SBBH = JBXX_SB.SBBH\n" +
            "where JBXX_DRDC.DCDR = '调出' and JBXX_DRDC.SHRQ is null\n")
    int getEquipmentTransferOutBasicListVoCount();

    // --------------调出详情--------------
    /**
     * @Description 管理员查看调出的详细信息
     * @author mzy
     * @time 2018-11-16
     * @see 
     * @return   edu.lsnu.equipment_management_system.pojo.vo.admin_resource.AdminEquipmentTransferOutVo
     * @params  [id] equipmentNo
     */
    @Select("select \n" +
            "DM_SBLB.SBLB 'equipmentCategory',\n" +
            "JBXX_SB.SBMC 'equipmentName',\n" +
            "JBXX_SB.SBBH 'equipmentNo',\n" +
            "JBXX_DRDC.CRRQ 'transerDate',\n" +
            "JBXX_DRDC.CRYY 'transerReason',\n" +
            "JBXX_DRDC.DCDW 'transerOutUnit',\n" +
            "JBXX_DRDC.DRDW 'transerInUnit',\n" +
            "YHB.XM 'handMan'\n" +
            "from JBXX_DRDC \n" +
            "inner join JBXX_SB\n" +
            "on JBXX_SB.SBBH = JBXX_DRDC.SBBH\n" +
            "inner join DM_SBLB\n" +
            "on JBXX_SB.SBLBDM = DM_SBLB.SBLBDM\n" +
            "inner join YHB\n" +
            "on JBXX_DRDC.ZGH = YHB.ZGH\n" +
            "where JBXX_DRDC.DCDR = '调出' and " +
            "-- and JBXX_DRDC.SHRQ is null \n" +
            "JBXX_DRDC.SBBH = #{equipmentNo}")
    AdminEquipmentTransferOutVo getEquipmentTransferOutDetailVo(String equipmentNo); // 20090322

    // --------------报损报废list--------------
    /**
     * @Description 管理员查看：报损报废列表
     * @author mzy
     * @time 2018-11-16
     * @see 
     * @return   java.util.List<edu.lsnu.equipment_management_system.pojo.vo.admin_resource.AdminMsgInVo>
     * @params  []
     */
    @Select("select\n" +
            "JBXX_BSBF.ZGH 'userNo',\n" +
            "YHB.XM 'userName',\n" +
            "JBXX_SB.SBMC 'equipmentName',\n" +
            "JBXX_BSBF.SBBH 'equipmentNo'\n" +
            "from JBXX_BSBF\n" +
            "inner join YHB\n" +
            "on YHB.ZGH = JBXX_BSBF.ZGH\n" +
            "inner join JBXX_SB\n" +
            "on JBXX_SB.SBBH = JBXX_BSBF.SBBH\n" +
            "where JBXX_BSBF.SHRQ is null\n" +
            "order by equipmentNo offset #{pageBegin} rows fetch next #{pageSize} rows only\n")
    List<AdminMsgInVo> getEquipmentDamageBasicListVo(PageBeginAndPageSizeVo pageBeginAndPageSizeVo);

    /**
     * @Description  管理员查看：报损报废列表count
     * @author mzy
     * @time 2018-11-23
     * @see 
     * @return   int
     * @params  []
     */
    @Select("select\n" +
            "count(JBXX_BSBF.SBBH)\n" +
            "from JBXX_BSBF\n" +
            "inner join YHB\n" +
            "on YHB.ZGH = JBXX_BSBF.ZGH\n" +
            "inner join JBXX_SB\n" +
            "on JBXX_SB.SBBH = JBXX_BSBF.SBBH\n" +
            "where JBXX_BSBF.SHRQ is null")
    int getEquipmentDamageBasicListVoCount();

    // --------------报损报废详情--------------
    /**
     * @Description 管理员查看：具体报损的详情
     * @author mzy
     * @time 2018-11-16
     * @see 
     * @return   edu.lsnu.equipment_management_system.pojo.vo.admin_resource.AdminEquipmentDamageVo
     * @params  [id] equipmentNo
     */
    @Select("select\n" +
            "DM_SBLB.SBLB 'equipmentCategory',\n" +
            "JBXX_SB.SBMC 'equipmentName',\n" +
            "JBXX_BSBF.SBBH 'equipmentNo',\n" +
            "YHB.XM 'handMan',\n" +
            "JBXX_BSBF.SFRQ 'damageDate',\n" +
            "JBXX_BSBF.SFYY 'damageReason',\n" +
            "DATEDIFF(year, JBXX_SB.JHRQ, JBXX_BSBF.SFRQ) 'useYear'\n" +
            "from JBXX_BSBF\n" +
            "inner join JBXX_SB \n" +
            "on JBXX_SB.SBBH = JBXX_BSBF.SBBH\n" +
            "inner join DM_SBLB\n" +
            "on JBXX_SB.SBLBDM = DM_SBLB.SBLBDM\n" +
            "inner join YHB\n" +
            "on YHB.ZGH = JBXX_BSBF.ZGH\n" +
            "where -- JBXX_BSBF.SHRQ is null and \n" +
            "JBXX_BSBF.SBBH = #{equipmentNo}")
    AdminEquipmentDamageVo getEquipmentDamageDetailVo(String equipmentNo); // 20030819

    // --------------运行使用list：注意运行使用没有详情--------------
    /**
     * @Description 运行使用的list
     * @author mzy
     * @time 2018-11-26
     * @see
     * @return   java.util.List<edu.lsnu.equipment_management_system.pojo.vo.out.admin.AdminUseRecordVo>
     * @params  [pageBeginAndPageSizeVo]
     */
    @Select("select \n" +
            "JBXX_SBSY.SBBH 'equipmentNo', \n" +
            "JBXX_SB.SBMC 'equipmentName',\n" +
            "JBXX_SBSY.ZGH 'userNo',\n" +
            "YHB.XM 'userName', \n" +
            "JBXX_SBSY.SYRQ1 'beginDate',\n" +
            "JBXX_SBSY.SYRQ2 'endDate',\n" +
            "DM_CFCS.CFCS 'place', \n" +
            "JBXX_SBSY.BZ 'remark'\n" +
            "from JBXX_SBSY \n" +
            "inner join DM_CFCS \n" +
            "on DM_CFCS.CFCSDM = JBXX_SBSY.CFCSDM\n" +
            "inner join YHB\n" +
            "on YHB.ZGH = JBXX_SBSY.ZGH\n" +
            "inner join JBXX_SB\n" +
            "on JBXX_SB.SBBH = JBXX_SBSY.SBBH\n" +
            "where JBXX_SBSY.SHRQ is null \n" +
            "order by beginDate offset #{pageBegin} rows fetch next #{pageSize} rows only\n")
    List<AdminUseRecordVo> getEquipmentUseRecordVo(PageBeginAndPageSizeVo pageBeginAndPageSizeVo);

    /**
     * @Description 运行使用的count
     * @author mzy
     * @time 2018-11-26
     * @see
     * @return   int
     * @params  []
     */
    @Select("select count(JBXX_SBSY.SYRQ1)\n" +
            "from JBXX_SBSY \n" +
            "inner join DM_CFCS \n" +
            "on DM_CFCS.CFCSDM = JBXX_SBSY.CFCSDM\n" +
            "inner join YHB\n" +
            "on YHB.ZGH = JBXX_SBSY.ZGH\n" +
            "inner join JBXX_SB\n" +
            "on JBXX_SB.SBBH = JBXX_SBSY.SBBH\n" +
            "where JBXX_SBSY.SHRQ is null ")
    int getEquipmentUseRecordVoCount();

    // --------------管理员对于运行使用的操作--------------
    /**
     * @Description 管理员通过设备编号查询一个设备的所有使用记录
     * @author mzy
     * @time 2018-11-23
     * @see 
     * @return   edu.lsnu.equipment_management_system.pojo.vo.out.admin.AdminUseRecordVo
     * @params  [pageBeginPageSizeAndEquipmentNoVo]
     */
    @Select("select \n" +
            "JBXX_SBSY.SBBH 'equipmentNo', \n" +
            "JBXX_SB.SBMC 'equipmentName',\n" +
            "JBXX_SBSY.ZGH 'userNo',\n" +
            "YHB.XM 'userName', \n" +
            "JBXX_SBSY.SYRQ1 'beginDate',\n" +
            "JBXX_SBSY.SYRQ2 'endDate',\n" +
            "DM_CFCS.CFCS 'place', \n" +
            "JBXX_SBSY.BZ 'remark'\n" +
            "from JBXX_SBSY \n" +
            "inner join DM_CFCS \n" +
            "on DM_CFCS.CFCSDM = JBXX_SBSY.CFCSDM\n" +
            "inner join YHB\n" +
            "on YHB.ZGH = JBXX_SBSY.ZGH\n" +
            "inner join JBXX_SB\n" +
            "on JBXX_SB.SBBH = JBXX_SBSY.SBBH\n" +
            "where JBXX_SBSY.SBBH = #{equipmentNo}\n" +
            "order by beginDate offset #{pageBegin} rows fetch next #{pageSize} rows only\n")
    List<AdminUseRecordVo> getEquipmentUseRecordVoByEquipmentNo(PageBeginPageSizeAndEquipmentNoVo pageBeginPageSizeAndEquipmentNoVo);

    /**
     * @Description 管理员通过设备编号查询一个设备的所有使用记录count
     * @author mzy
     * @time 2018-11-23
     * @see
     * @return   int
     * @params  [equipmentNo]
     */
    @Select("select \n" +
            "count(JBXX_SBSY.SYRQ1)\n" +
            "from JBXX_SBSY \n" +
            "inner join DM_CFCS \n" +
            "on DM_CFCS.CFCSDM = JBXX_SBSY.CFCSDM\n" +
            "inner join YHB\n" +
            "on YHB.ZGH = JBXX_SBSY.ZGH\n" +
            "inner join JBXX_SB\n" +
            "on JBXX_SB.SBBH = JBXX_SBSY.SBBH\n" +
            "where JBXX_SBSY.SBBH = #{equipmentNo}")
    int getEquipmentUseRecordVoByEquipmentNoCount(String equipmentNo);
}
